package com.ly.mpayment.persist.common;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * SessionListener.java
 * session监听器
 * @author 
 * 2013-6-17
 * Version 1.0
 */
public class SessionListener implements HttpSessionListener {
	
	private static final Log log = LogFactory.getLog(SessionListener.class);

	public static Map<String, Object> sessionMap = new HashMap<String, Object>();
	
	private static SessionContext context = SessionContext.getInstance();
	
	
	
	public void sessionCreated(HttpSessionEvent event) {
		HttpSession session  = event.getSession();
//		session.setMaxInactiveInterval(1*60);
		context.addSession(session);
		log.debug("加入新Session--"+event.getSession().getId());
	}

	public void sessionDestroyed(HttpSessionEvent event) {
		context.removeSession(event.getSession());
		log.debug("移除session--"+event.getSession().getId());
	}
	
	public static SessionContext getContext(){
		return context;
	}
	
	

}
